package com.itheima.demo;

public class Day06 {
    String brand;
    int name;
    public void huMan(){
        System.out.println("111");
    }
    public static void main(String[] args){
        int a=5,b=10;
        System.out.println(a^b);
        System.out.println(a^b^b);
        System.out.println(a^b^a);
        /*int a=10,b=20;
        a=a^b;
        b=a^b;  //b=a;
        a=a^b;  //a=b;
        System.out.println("a:"+a+" b:"+b);*/
        int[] arr = new int[]{1,2,3,4,5,6,7,8,9};
       // Arrby(arr,520);
        //findArr(arr,5);
    }
    public static void Arrby(int[] arr,int num){
        for (int i = 0; i < arr.length; i++) {
            arr[i]=num;
        }
        forArr(arr);
    }//将接收的数组元素全改为num
    public static void arrAvg(int start,int end,int num,int[] arr){
        for (int i = start; i <end; i++) {
                arr[i]=num;
        }
        forArr(arr);
    }//从start位开始到end位结束的索引数组元素全部改为num,打印新数组
    public static void forArr(int[] arr) {
        System.out.print("[");
        for (int i = 0; i < arr.length; i++) {
            if (i == arr.length - 1) {
                System.out.print(arr[i]);
            } else {
                System.out.print(arr[i] + ",");
            }
        }
        System.out.println("]");
    }//遍历输出一个数组
    public static void Arrder(int[] arr1,int[] arr2) {
        if (arr1.length==arr2.length){
            for (int i = 0; i <arr1.length ; i++) {
                if (arr1[i]!=arr2[i]){
                    System.out.println("第"+(i+1)+"个元素不同");
                    return;
                }
            }
            System.out.println("数组相同!");
            return;
        }else{
            System.out.println("数组长度不同");
        }

    }//判断接收的两个数组是否相同
    public static void findArr(int[] arr,int num){
        for (int i = 0; i < arr.length; i++) {
            if (arr[i]==num){
                System.out.println("第"+(i+1)+"位元素相同");
                return;
            }
        }
    }//找到数组中数值与num相同的索引
}
